/**
 * 
 */
package com.boronstream.istar.http;

import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;

/**
 * @author Stream
 * 
 */
public interface PlayClient {

	/**
	 * execute the public request
	 * 
	 * @param request
	 * @return
	 */
	public <T extends PlayResponse> T execute(PlayRequest<T> request);

	public class BaseHttpClient extends DefaultHttpClient {

		public BaseHttpClient() {
			HttpParams params = new BasicHttpParams();

			HttpConnectionParams.setConnectionTimeout(params, 60 * 1000);
			HttpConnectionParams.setSoTimeout(params, 60 * 1000);
			HttpConnectionParams.setSocketBufferSize(params, 8192);

			HttpClientParams.setRedirecting(params, true);

			// TODO:
			String userAgent = "";
			HttpProtocolParams.setUserAgent(params, userAgent);
			setParams(params);
		}
	}

}
